Time-synchronized, multizone media streaming

ABSTRACT

In a general aspect, a system for media playback can include a first media playback device configured to receive a media stream from a media casting device over a data network, the first media playback device being a member of the media playback group and a second media playback device configured to receive the media stream, the second media playback device being a member of the media playback group. The first media playback device and the second media playback device can be collectively configured to designate one of the first media playback device and the second media playback device as a leader playback device of the media playback group. The playback device not designated as the leader playback device can be designated as a follower playback device of the media playback group. The first media playback device and the second media playback device can be further collectively configured to determine a clock offset between the leader playback device and the follower playback device. The leader playback device can be configured to receive a broadcast of the media stream over the data network; play the media stream; and provide the media stream to the follower playback device. The follower playback device can be configured to play the media stream in synchronization with the leader playback device based on the clock offset.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/762,903, filed Mar. 23, 2018, which is a national stage applicationunder 35 U.S.C. § 371 of International Patent Application No.PCT/US2016/053350, filed Sep. 23, 2016, which claims the benefit of U.S.Provisional Patent Application No. 62/233,972, filed Sep. 28, 2015, eachof which is hereby incorporated by reference herein it its entirety.

TECHNICAL FIELD

This disclosure relates to media streaming. More specifically, thisdisclosure relates to time-synchronized media streaming on multipledevices (e.g., multizone media streaming).

SUMMARY

In a general aspect, a system for media playback can include a mediacasting device configured to broadcast a media stream to a data networkfor playback by a media playback group; a first media playback deviceconfigured to receive the media stream, the first media playback devicebeing a member of the media playback group; and a second media playbackdevice configured to receive the media stream, the second media playbackdevice being a member of the media playback group. The first mediaplayback device and the second media playback device can be collectivelyconfigured to designate one of the first media playback device and thesecond media playback device as a leader playback device of the mediaplayback group. The one of the first media playback device and thesecond media playback device not designated as the leader playbackdevice can be designated as a follower playback device of the mediaplayback group. The first media playback device and the second mediaplayback device can be further collectively configured to determine aclock offset between the leader playback device and the followerplayback device. The leader playback device can be configured to receivethe broadcast of the media stream from the data network; play the mediastream; and provide the media stream to the follower playback device.The follower playback device can be configured to play the media streamin synchronization with the leader playback device based on the clockoffset.

Implementations can include one or more of the following features. Forinstance, the first media playback device and the second media playbackdevice can each include a respective record indicating membership in themedia playback group. The media playback group can be a first mediaplayback group, and the respective record of the first media playbackdevice can further indicate membership in a second media playback group.

The system can include a third media playback device configured toreceive the media stream. The third media playback device can be amember of the media playback group. The third media playback device andthe leader playback device can be collectively configured to determine aclock offset between the leader playback device and the third playbackdevice. The leader playback device can be configured to provide themedia stream to the third media playback device. The third mediaplayback device can be configured to play the media stream insynchronization with the leader playback device based on the clockoffset between the leader playback device and the third playback device.

Designating one of the first media playback device and the second mediaplayback device as a leader playback device of the media playback groupcan include comparing a measure of quality of a data connection of thefirst media playback device with the data network and a measure ofquality of a data connection of the second media playback device withthe data network.

Each of the first media playback device and the second media playbackdevice can be configured to implement a broadcast service to broadcast amessage indicating membership in the media playback group. Thebroadcasted message can include a query requesting a response from mediaplayback devices that are connected to the data network and members ofthe media playback group.

The leader playback device providing the media stream to the followerplayback device can include providing the media stream to the followerplayback device in a sequence of timestamped data packets.

Playing, by the follower playback device, the media stream insynchronization with the leader playback device based on the clockoffset can include playing, by the follower playback device, the mediastream in synchronization with the leader playback device based on theclock offset and an output delay of the follower playback device. Theclock offset can be determined based on a round-trip-time (RTT) betweenthe leader playback device and the follower playback device.

In another general aspect, a method can include connecting a first mediaplayback device with a data network, the first media playback devicebeing operationally associated with a media playback group andconnecting a second media playback device with the data network, thesecond media playback device being operationally associated with themedia playback group. The method can further include designating one ofthe first media playback device and the second media playback device asa leader playback device of the media playback group, where the one ofthe first media playback device and the second media playback device notdesignated as the leader playback device can be designated as a followerplayback device of the media playback group. The method can also includedetermining a clock offset between the leader playback device and thefollower playback device; receiving, at the leader playback device, amedia stream for playback by the media playback group and playing themedia stream by the leader playback device. The method can still furtherinclude providing, by the leader playback device, the media stream tothe follower playback device and playing, by the follower playbackdevice, the media stream in synchronization with the leader playbackdevice based on the clock offset.

Implementations can include one or more of the following features. Forinstance, connecting the first media playback device with the datanetwork can include the first media playback device sending a broadcastmessage indicating the first media playback device's membership in themedia playback group. The broadcast message can include a queryrequesting a response from media playback devices that are connected tothe data network and operationally associated with the media playbackgroup. The media playback group can be a first media playback group andthe broadcast message can indicate the first media playback device'smembership in a second media playback group. Connecting the second mediaplayback device with the data network can include the second mediaplayback device sending a broadcast message indicating the second mediaplayback device's membership in the media playback group.

Designating one of the first media playback device and the second mediaplayback device as the leader playback device can include determining aleadership metric for the first media playback device; determining aleadership metric for the second media playback device; and designatingone of the first media playback device and the second media playbackdevice as the leader playback device based on a comparison of theleadership metric for the first media playback device and the leadershipmetric for the second media playback device. The leadership metric forthe first media playback device can be based on one or more attributesof a network connection of the first media playback with the datanetwork. The leadership metric for the second media playback device canbe based on one or more attributes of a network connection of the secondmedia playback with the data network.

Determining the clock offset between the leader playback device and thefollower playback device can include, iteratively: sending, by thefollower playback device, a synchronization request including atimestamped packet to the leader playback device, the timestamped packetindicating a time of a clock of the follower playback device; receiving,by the leader playback device, the synchronization request from thefollower playback device; sending, by the leader playback device inresponse to the synchronization request, a synchronization responseincluding an indication a time of a clock of the leader playback deviceand the time of the clock of the follower playback device included inthe synchronization request; and determining, by the follower devicebased on the synchronization response: a round-trip-time (RTT) of thesynchronization request and synchronization response; and the clockoffset based on the RTT. Determining the RTT can include calculating atleast one of a weighted moving average and a linear regression based ontwo or more synchronization responses.

Providing the media stream to the follower playback device can includeproviding the media stream to the follower playback device in a sequenceof timestamped data packets. The method can include buffering, by theleader playback device and the follower playback device, respectiveportions of the media stream.

The follower playback device can be a first follower playback device,and the method can include connecting a third media playback device withthe data network. The third media playback device can be operationallyassociated with the media playback group. The method can includedesignating the third media playback device as a second followerplayback device and determining a clock offset between the leaderplayback device and the second follower playback device. The method caninclude providing, by the leader playback device, the media stream tothe second follower playback device and, playing by the second followerplayback device, the media stream in synchronization with the leaderplayback device based on the clock offset between the leader playbackdevice and the second follower playback device.

The method can include sending, by the follower playback device to theleader playback device, an indication that the follower playback deviceis leaving the media playback group. In response to the indication, themethod can include discontinuing, by the leader playback device,providing the media stream to the follower device and updating, by theleader playback device, membership information for the media playbackgroup to remove the follower playback device.

Playing, by the follower playback device, the media stream insynchronization with the leader playback device based on the clockoffset can include playing, by the follower playback device, the mediastream in synchronization with the leader playback device based on theclock offset and an output delay of the follower playback device.

The media stream can be a first media stream, and the method can includereceiving, at the leader playback device, a request to playback a secondmedia stream by the media playback group. In response to the request toplayback the second media stream, the method can include stoppingplayback of the first media stream by the leader playback device and thefollower playback device. After stopping playback of the first mediastream, the method can include playing the second media stream by theleader playback device; providing, by the leader playback device, thesecond media stream to the follower playback device; and playing, by thefollower playback device, the second media stream in synchronizationwith the leader playback device based on the clock offset.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a system for multizone mediastreaming.

FIG. 2 is a diagram illustrating components of the system of FIG. 1 andcommunication between those components.

FIG. 3 is a flowchart illustrating a method for time-synchronized mediaplayback to a media playback group including a plurality of playbackdevices.

FIG. 4 is a flowchart illustrating a method for designating a leaderdevice of a media playback group.

FIG. 5 is a flowchart illustrating a method for determining a clockoffset between a leader device and a follower device of a media playbackgroup.

FIG. 6 is a flowchart illustrating a method for adding a playback deviceto a media playback group that is currently playing media.

FIG. 7 is a flowchart illustrating a method for a playback deviceleaving a media playback group.

FIG. 8 is a flowchart illustrating a method for changing a media streamthat is being played by a media playback group.

FIG. 9 is a flowchart illustrating a method for determining an audiooutput delay of a media playback device.

FIG. 10 is a diagram illustrating an example of a computer device and amobile computer device that can be used to implement the techniquesdescribed here.

Like reference symbols in the various drawings indicate like elements.Reference numbers for some like elements may not be repeated for allsuch elements.

DETAILED DESCRIPTION

This disclosure is directed to systems and methods for media (e.g.,audio streaming), where playback is time-synchronized across multipleplayback devices (e.g. multizone playback). While the approachesdescribed herein are generally discussed with respect to streaming(playback) of audio content, it will be appreciated that the approachesdescribed herein may also be used for playback of other types of media,such as video, photographs, etc.

When playing media from a common source (e.g., a media source device) ona multiple playback devices over a data network, variation in respectivenetwork connection quality for the multiple playback devices can resultin playback time delays between the multiple playback devices. Suchplayback time delays can negatively impact a user's experience. Usingthe approaches described herein, media can be played back by a mediaplayback group that includes a leader playback device (leader device)and one or more follower playback devices (follower devices). In suchimplementations, the leader device, using the approaches describedherein, can be respectively time-synchronized (e.g., determine arespective clock offset and/or respective clock drift) with each of thefollower devices to account for variations in network connection forrespective playback devices (leader device and/or follower devices). Theleader device can receive (e.g., from a media source device) a mediastream for playback by the leader device and the follower devices (themedia playback group). The leader device can then play the receivedmedia stream and also provide the received media stream to itsassociated follower devices. The follower device can play the mediastream, received from the leader device, based on their respectivetime-synchronization with the leader device.

FIG. 1 is a block diagram illustrating a system 100 that can be used formultizone, time-synchronized media streaming (media playback), accordingto an implementation. The system 100 is shown by way of example and forpurposes of illustration. In other embodiments, multizone mediastreaming systems can have a number of other configurations.

As illustrated in FIG. 1, the system 100 includes a first user device110 (e.g., which can be used to start and stop media casting(broadcasting) and/or provide media for streaming) and a second userdevice 120. The user devices 110 and 120 can take a number of forms,such as a smartphone, a laptop computer, a netbook computer, a mediaplayer device, a television, etc. For instance, in the system 100 ofFIG. 1, the user devices 110 and 120 can be computing devices with datanetwork communication capabilities.

The system 100 of FIG. 1 also includes a first playback group leaderdevice 130 and a second playback group leader device 140. The leaderdevices 130 and 140 may be devices capable of playing streaming media(e.g., media received from the user devices 110 and 120 and/or media ona data network, such as the Internet, which the leader playback devices130, 140 can obtain for media casting purposes) and also have datanetwork communication capabilities (e.g., for obtaining and/orcommunicating media data and control data) with other playback devicesof the multizone media streaming system 100, such as described herein.

The system 100, as shown in FIG. 1, also includes a first playback groupfollower device 150, a second playback group follower device 160 and athird playback group follower device 170. The leader devices 130 and 140may be devices capable of playing streaming media (e.g., media receivedfrom the user devices 110 and 120, media received from the Internet,etc.) and also have data network communication capabilities (e.g., forcommunication with the other devices of the multizone media streamingsystem 100). Media received at a leader device (130, 140) can then betime-synchronized and played back (cast, streamed, etc.) by the leaderdevice and corresponding follower devices (150, 160, 170) using theapproaches described herein. In some implementations, a given playbackdevice can be a leader device and/or a follower device in multipleplayback groups.

As shown in FIG. 1, the follower device 150 and the follower device 160are operationally coupled with the leader device 130 in a firstmultizone media streaming group. Similarly, the follower device 160 andthe follower device 170 are operationally coupled with the leader device140 in a second multizone media streaming group. In the system 100, thefollower device 160 is a member of (operationally associated with) boththe first multizone media streaming group and the second multizone mediastreaming group. In other implementations, other arrangements arepossible, for instance, the system could include additional or fewermedia source devices, have additional or fewer playback groups, haveplayback groups with single devices, and so forth.

In the system 100, the determinations as to which of the playback groupdevices 130-170 are leader devices and which devices are followerdevices for a given playback group can be determined dynamically, suchas using the approaches described herein. Using such approaches, thoughnot shown in FIG. 1, a playback device that is a follower device in oneplayback group may be a leader device in another playback group, andvice versa. Devices within a playback group can operate in conjunctionwith each other to play a media stream (e.g., a digital audio stream orthe like) using time-synchronization (e.g., such as in accordance withthe approaches described herein) to synchronously playback the mediastream on the each of the playback (e.g., leader device and followerdevices) of a given playback group.

In an implementation, configuration of a playback group, such asdiscussed herein, can be done on a per device (playback device) basis.For example, a given playback device (e.g., in the system 100) can keeptrack of which playback groups (groups) it is a member of withoutrelying on a centralized, canonical source that maintains groupmembership information. In such implementations, playback devices mayonly be added to and/or removed from a group when they are online.

In such approaches, when a playback device comes online (or is added toa group), it can announce its group membership using a multicast DomanName System (mDNS) broadcast message (or other appropriate mechanism),such as is shown in FIG. 2. Based on such messages, other onlineplayback devices (that are already online) in the system 100, or othermultizone media streaming system, can dynamically determine the groupmembership of all devices as they come online. The newly online playbackdevice also can also send an mDNS request (or other appropriate protocolrequest) for the group membership information of existing onlinedevices. Based on responses to this request, the newly online device canbuild group membership information of all other online devices.Similarly, when a playback device is removed from (leaves) a groupand/or joins another group, it can announce its new group configurationso that other online devices can update their group membership knowledgefor the announcing device.

When a group is disbanded (e.g., the group is removed from availableplayback groups) a disband notification can be sent to devices in thatplayback group. However, some devices that are members of the disbandedgroup may not be online to receive a corresponding disband notification.In such instances, in order to avoid a disbanded group showing up again(e.g., in a list of available playback groups displayed to a user on amedia source device, e.g., user devices 110, 120) when those groupmembers that were offline at the time of the disband notification comeonline, the group disband notification can be persistently stored in alllocal, online devices (e.g., until all group members are notified). Whena previously offline device of the disbanded group next comes online andannounces its membership in a disbanded group, the other online devicescan then send the previously offline device the previous disbandnotification. In some instances, a newly online device may not realizethat a group it was a member of has been disbanded (e.g., no members ofthe disbanded group are online when it announces its membership in thedisbanded group). In such instances, the group can just be disbandedagain (e.g., by a user from a media source device, such as user devices110, 120).

In certain implementations, each playback group of the system 100, forexample, can be identified by a universally unique identifier (UUID),which can be randomly generated at the time a given playback group iscreated. Such UUIDs can be used to determine group membership, and alsoto identify groups which have been disbanded. In certainimplementations, a user can create two logically different groups(different UUIDs) with the same (e.g., text label) name and/or aplayback group can have multiple devices that have the same (e.g., textlabel) name.

In other implementations, cloud-based storage (e.g., local cloudstorage, Internet cloud storage, etc.) can be used for maintaining groupmembership information. Such implementations would allow for the abilityto display group members that are offline, and the ability to remove anoffline device from a group, as playback group information is maintainedseparately from the devices of a given playback group. In such anapproach, on startup, a device that was removed from a group while itwas offline can, as part of an initialization process when it comesonline, synchronize with membership information in the cloud-basedstorage for each group that it is (thinks that it is) a member of (e.g.,keyed by the groups' UUIDs) to determine if it has been removed from thegroup (or if the group has been disbanded). Similarly, playback devices(e.g., leader devices 130, 140 and follower devices 160, 170, 180) coulduse such cloud-based membership information to determine full groupmembership for each group they are a member of (think they are a memberof).

As briefly noted above, a playback group configuration process caninclude each playback device that is a member of at least one group(e.g., of a local media playback and/or media casting system)transmitting (broadcasting) a “service announcement” (e.g., an mDNS)message to other online playback devices, such as illustrated in FIG. 2.In an example implementation, such a message can be a text (TXT) record,where the first entry in the TXT record can be the device ID (e.g., inthe format “id=<device ID>”). Additional entries in the TXT record canlist all the groups that the given playback device is a member of. Forexample, a corresponding entry for each playback group that a device isa member of can contain a group name and an UUID; an indication whetherthe given device thinks it is currently the leader of the given playbackgroup; an indication whether the given playback group is currentlycasting (playing) media (e.g., in the TXT record of the playback groupleader device).

In some implementations the entries can be DNS-based Service Discovery(DNS-SD) TXT records that conform with the requirements of RFC 6763section 6. For example, the group list can be a list of<length><key>=<value> entries, one entry per group. The <key> can be thegroup UUID encoded as lowercase hexadecimal; the <value> can be encodedas <flags>|<group name>, where <flags> contain bit flags about thecurrent group state, encoded as a base-10 integer. Such flags can be asfollows, though other flags are possible. For instance, a flag with avalue of 0x01 can indicate that a corresponding playback device is(believes it is) the current group leader of a given playback group. Aflag with a value of 0x02 can indicate that the corresponding playbackgroup is currently playing media that is being casted. A flag with avalue of 0x04 can indicate that the corresponding device has beenexplicitly configured as the playback group leader. In otherimplementations, other flags and/or other flag values can be used.

A service (SRV) record, which can be included in DNS information for thedevices of the system 100, can contain a “leadership metric” in priorityand weight fields (e.g., as a 32-bit metric) of the record. The SRVrecord can also contain a host IP address and a port ID of theadvertised service. The leadership metrics (of all members of a group)can be used by each group member to determine which device should be theplayback group leader for a given playback group (e.g., the device withthe largest leadership metric can be selected (identified) as theleader). In an implementation, the leadership metric for a givenplayback device can be determined as follows.

If a playback device (e.g., one of the follower devices 150, 160, 170)does not have the ability to be a playback group leader, such as due tolimited CPU/memory, it can return a 0 as its leadership metric. Fordevices with the ability to function as a playback group leader, aleadership metric can be determined as a measure of network quality fora given playback device. In an implementation, this measure can becalculated as follows. If the given playback device is connected to acorresponding playback system (playback group) via an Ethernetconnection, the measure of network quality can be set to 100*65536.Otherwise, the measure of network quality can be set to 10*65536+thegiven playback device's (measured) WiFi signal-to-noise ratio (SNR) indBm. If the WiFi network is 5 GHz, the SNR value used in thedetermination of the network quality measure can be given, for example a“boost” (e.g., a value added to the measured SNR for the given playbackdevice) to determine an effective SNR value that can be used todetermine a leader device for a given playback group (by comparison witheffective SNR values of other playback devices of the playback group).If a playback device is “always on”, its quality measure can bemultiplied by an implementation dependent (scaling, weighting, etc.)constant.

In certain implementations, other approaches for determining aleadership metric (quality measure) can be used. For instance, anadditional boost to the effective SNR value used to determine aleadership metric can be added for playback devices connected to aplayback group via 5 GHz WiFi if their measured SNR exceeds an SNRthreshold value (e.g., a 25 dBm threshold in an example implementation).For instance, this additional effective SNR boost can be determined as3*(measured or effective SNR−SNR threshold), where the multiplier valueof (3 in the example) can vary based on the specific implementation.Further, in certain implementations, for playback devices connected viaWiFi at any frequency, another additional fixed boost value (e.g., 6dBm) can be given to (added to, etc.) the effective SNR value (e.g., themeasured SNR plus any previously added boost values) that is used todetermine a leadership metric for a playback device that is currentlydesignated as a playback group leader, which can reduce the frequency ofthe playback group leader role being swapped between devices of anassociated playback group due to fluctuations in respective SNRs of theplayback devices (e.g., measured/actual SNRs).

Using the above approaches, an effective SNR (effective_SNR) value foruse in calculating leadership metrics for a playback device that isconnected to a playback group via a WiFi connection can be calculated(determined) using the following sequence. Initially, an effective_SNRvalue for a given playback device can be set as being equal to themeasured (actual) SNR of that device. If the WiFi connection frequencyis 5 GHz, a 5 GHz boost value (e.g., 8 dBm, 10 dBm, etc.) can be addedto the previous effective_SNR value (e.g., the actual SNR in thisexample). Further, if the WiFi connection frequency for the givenplayback device is 5 GHz and the measured SNR is above the SNR thresholdvalue, an additional boost value proportional to the measured SNR (suchas discussed above) can be added to the previously determinedeffective_SNR value. Still further, if the given playback device iscurrently designated as the leader device of an associated playbackgroup, another additional boost the effective_SNR value can be made(e.g., 6 dBm, such as discussed above).

Using the approaches described herein, playback group members, e.g., inthe system 100, can discover each other as they come online, and keeptrack of other group members using casting service queries and castingservice announcements (e.g., mDNS messages), such as shown in FIG. 2.For instance, when a (playback) device of the system 100 comes online orwhen its group membership changes, it can announce such events and/orchanges. The playback device coming online can also query all otherlocal playback devices. After a timeout period (e.g., 1 second), theplayback device coming online can determine the group leader for eachplayback group that it is a member of. For example, the leader device ofa playback group can be determined using the approach discussed below.

If there is only one playback device in the playback group (e.g., onedevice that is active, online, etc.), that device is designated as theplayback group leader. If the playback group is currently casting(streaming) media, the playback device that is designated as theplayback group leader remains the leader until the media casting ends.Otherwise, the playback device with the highest leadership metric (e.g.,effective_SNR value) is made the playback group leader. If multipledevices have the same leadership metric, a leader device can bedetermined by comparing IP addresses of those multiple devices. In oneimplementation, the playback device with the lowest IP address can beselected as the leader. In another implementation, the playback devicewith the highest IP address can be selected as the leader. In otherimplementations, other approaches (e.g., using other parameters) can beused to determine a leader from playback devices with equal leadershipmetric values.

Once a given playback device determines a group leader (assuming it isnot the leader) for a playback group it is a member of, the playback(follower) device can set up a reliable data transport connection, e.g.,a TCP connection, with the leader device, where the data transportconnection can then be used to authenticate the follower device and setup encryption keys. In an example implementation, a TCP connectiontimeout can be 15 seconds. If a given TCP connection times out for afollower device, the associated leader device can be assumed to beoffline (e.g., dead), and the follower device (e.g., in cooperation withother devices in playback group of the system 100) can determine a newleader (e.g., starting by re-querying playback devices in the associatedplayback group). To determine if the leader device is active, the givenfollower device can, alternatively, start sending clock synchronization(sync) requests to the leader device. Each follower device in a playbackgroup can send such clock sync requests to the leader device at leastonce every 5 seconds. If a follower device does not receive any clocksync responses (from an indicated leader device) within 20 seconds, itcan assume that the indicated leader device has been lost (e.g., hasgone offline, was unplugged, disconnected, etc.) and a new leader forthe associated playback group can be determined (e.g., starting byre-querying). Whenever the playback group leader device changes,associated follower devices should establish contact (e.g., TCP and timesync) with the new leader device.

In an implementation, if a playback device thinks it should become thenew group leader of a given playback group, that playback device can gointo a probing state, placing its SRV and TXT records (as discussedabove) into an authority section of a corresponding probe query. Uponreceiving this query, the current leader (if any) checks to see if theprobing device should actually be the leader (e.g., based on leadershipmetrics). If the current leader determines it should be replaced, itshould immediately send goodbye packets for its leader service andderegister as the group leader. The probing device can finish probing(e.g., in approximately 1 second, or less) after the deregistration ofthe previous leader device and become the new leader. In suchapproaches, there can be a short time window (e.g., approximately 1second, or less) where there is no leader for a given playback group.

In certain implementations, the leader of a playback group cannot bechanged during a group cast (e.g., multizone media cast). In suchimplementations, if the group leader goes offline, the cast stops.Similarly, if a user casts, e.g., from user device 110 or user device120, a different media stream (different than a media stream that iscurrently being casted) directly to a currently casting group's leaderdevice (or another group containing the leader), the first (current)group cast can stop. In such approaches, for purposes of user experienceconsistency, if a user casts to any member of a currently casting group(or another group that overlaps the currently casting group), thecurrent group cast may stop and the new cast can then play on the targetplayback device/playback group. However, in comparison, in suchimplementations, if playback group members (follower devices) of acurrently casting group go offline and/or become unavailable for someother reason, the group cast may not stop, which will avoid a playbackgroup media cast from repeatedly stopping and starting if one (or more)playback group follower member (e.g., due to a bad network connectionand/or other issue) repeatedly cycles between being online and offline.

In order to support compatibility between different media players and/ormedia casting applications when performing a group media cast, ascompared to casting to a single device, a playback group leader (if any)can announce itself as a playback service with an associated group name,but pointing at (designating) a different port (for the group playbackservice) from its normal default media casting port so that launchrequests for the playback group can be differentiated from launchrequests for that specific device (e.g., as a single casting device thatis not part of a playback group). In such approaches, the casting groupmay then operate as a virtual device. Note that, in someimplementations, a playback device may not announce a group cast serviceif there is only one online group member.

However, in certain implementations, every media casting session (e.g.,every media casting session requested by the user device 110 or the userdevice 120 in the system 100 of FIG. 1) can be configured to operate asa group cast (even for cast requests that are initially made to a singleplayback device, rather than to a predefined casting group). Such anapproach (which can be referred to as implementing on-demand groups, orgroups-on-demand) can be implemented by having all media castingsessions that are initially sent to a single playback device be set upusing the approaches described herein for multiple playback devicecasting groups (e.g., using a multizone media casting backend for mediaoutput). In such implementations, follower devices can be easily addedto/removed from an associated casting session at any time during thecast, such as using the techniques described herein.

Once a group-on-demand casting session is created, it can behave in thesame way as a predefined group casting session. For instance, pause,resume, and other functions can be configured to work from any device ina group-on-demand. Further, playback group volume functions (e.g., groupvolume and individual device volume), such as described herein, can beconfigured to operate in like manner for a group-on-demand as for apredefined playback group. Implementing such groups-on-demand caninclude each playback device including (defining) a “virtual group”membership entry (e.g., in a respective TXT record), where the virtualgroup membership for a given playback device is defined to only containthat playback device. In such approaches, associated media castingsystems, such as the system 100, can be configured such that thesevirtual groups do not show up as being selectable by a user (e.g., in amedia casting, sender, application) as a playback device that isavailable for casting. The virtual group can be used, however, toutilize (leverage) functionality for media playback by predefinedcasting groups.

In certain implementations, playback devices that are added to a mediacast for a group-on-demand can be considered to be “temporary” membersof the corresponding playback group that is being casted to. Saidanother way, in such implementations, as soon as such a cast sessionstops (and an associated group-on-demand is unlaunched or disbanded),the temporary members can be configured to remove themselves from thatgroup-on-demand.

In order to join an ongoing cast session (e.g., join a group-on-demand),playback devices in a multizone media casting system, such as the system100, can be configured to be able to discover all in-process mediacasting sessions on a given network. For example, playback devices canbe configured to listen to an mDNS service, where flags are used toindicate playback groups that are currently casting. In implementationsthat include groups-on-demand, because all casts can be associated witha group (including virtual groups for single device casts), the mDNSservice can provide information about all current media castingsessions.

In an implementation, a currently casting device can be configured tosend a signal to one or more other available casting devices on the samenetwork to have those other devices join (playback) the same media castas the currently casting device. The mDNS service noted above can beused by the currently casting device to identify the one or more otheravailable casting devices. Note that playback devices that are alreadypart of the casting group of the currently casting device (permanentlyor temporarily) can ignore this signal.

In order to provide media stream playback temporal synchronizationbetween leader devices 130, 140 and follower devices 150, 160, 170 in agiven media casting playback group in the system 100 (or other multizonemedia playback system), each follower device in a playback group cantrack a time offset between its (e.g., monotonic) system clock and theplayback group leader's (e.g., monotonic) system clock. In animplementation, this offset can be determined using a round-trip-timebased (RTT-based or rtt-based) method with weighted average smoothingand/or linear regression smoothing. Such approaches will be discussed infurther detail below. With such temporal synchronization, leader devicesand associated follower devices can account for network latency (e.g.,variations in network quality, such as WiFi quality), which allows theleader device and follower devices of a given playback group to playbackmedia at a same time (substantially a same time) without perceptibleplayback time delay from one playback device to another, thus improvinga user's experience.

Briefly, time (clock) synchronization between devices in a playbackgroup in the system 100 can be accomplished using unicast UDP requestpackets sent by a follower device (e.g., follower devices 150, 160, 170)to a corresponding leader device (e.g., leader devices 130, 140)containing the follower's current clock time. In other implementations,use of other protocols is possible. After receiving the request packet,the leader device can then respond with its own clock time and thefollower's clock time copied from the request (e.g., so that thefollower device does not need to track request order). The followerdevice can use this response to estimate the RTT and the clock offset.

In certain implementations, a follower device in the system 100 can sendrequests at a rate determined by the follower's clock offset errorestimate (e.g., if the follower thinks it doesn't have a good estimateof the clock offset, it can send time synchronization requests morefrequently). If a given playback group is not currently casting,follower devices of the given playback group can simply send suchrequests approximately once every 5 seconds. Such an approach can alsobe used be used to detect when a leader goes offline withoutnotification. Once a media cast has been launched, the follower devicesmay increase their clock (time) sync request rates up to once every 50milliseconds, or more frequently (with a minimum period of once every 5seconds, depending on the offset accuracy).

In an example implementation, raw clock offset estimates can be smoothedusing a moving linear regression with a window size of 10 minutes toprovide an accurate clock offset estimate. In such approaches, the RTTestimates from time sync requests are smoothed and used to determinewhen NACKs should be sent for audio stream packets, such as using theexample approaches discussed in detail below.

Follower devices of a casting group in the system 100 of FIG. 1, or inother multizone media casting systems, can all connect to an associatedleader device (e.g., as soon as the leader is known) using apeer-to-peer transport control protocol (TCP) and set up a transportlayer security (TLS) connection using any number of appropriateauthentication techniques. When a multizone media cast is launched, thecorresponding leader device can create a new random secret key whichwill be used for encryption of data sent between cast (playback) groupmembers. This key can distributed to all follower devices over therespective TLS connections. If a follower device joins a playback group(comes online) partway through a cast, the leader can send the secretkey to it as well. All media content (and other data) can be encryptedusing the secret key using any number of appropriate encryptionprotocols. Clock (time) sync packets may not be encrypted orauthenticated in any way. Control messages, however, may be encryptedand sent over the TLS connection.

When a group cast is launched, such as in the system 100 using theapproaches described herein, a rendering process on the leader devicefor associated media content can be configured to redirect demuxedaudio/video streams to a multizone (group) process for local playback(e.g. by the leader device) and for distribution (e.g., of audio data)to follower devices (e.g., for playback by the follower devices). Thiscan be done using any number of appropriate media rendering services.Digital rights management can be managed using software, hardware and/orfirmware, as appropriate for the particular implementation.

When a group launch request (e.g., group media playback request) isreceived, the designated leader device (e.g., determined using theapproaches described herein) can send a launch notification to allfollowers over a TCP control channel. This notification can containmetadata about the requested group media cast and can also indicate thatthe follower devices should prepare for that media to be casted. Inresponse to the launch notification, follower devices can increase theirclock (time) sync request rates up to once every 50 milliseconds (ifrequired/needed), where the time sync request rate for a given followerdevice can be based on that follower's clock offset error estimate. Alaunch notification can also sent to any follower that joins after thecast has begun.

Once audio data (of the requested cast) is available, the leader (e.g.,the leader device 130) can stream it to all available follower devices(e.g., the follower devices 150 and 160). The audio data, in thisexample, can be streamed in the format described below. Each followerdevice can begin playback of the audio data once it has achieved areasonably good clock offset estimate (e.g., when its respective clockoffset error estimate is less than 5 milliseconds). In most instances,this playback will be immediate as there can be a period of severalseconds between the cast launch request and media (e.g., audio data)beginning to stream, allowing sufficient time for clock synchronizationbetween the leader device and it associated follower devices to beaccomplished.

In the system 100, audio data (or other media data) can be streamedfrom, for example, the leader device 130 to the corresponding followerdevices 150, 160 using real-time transport protocol (RTP) over userdatagram protocol (UDP) with retransmissions (e.g., see RFC 4588). Inimplementations using RTP for audio streaming, each audio data streamcan be identified using a distinct synchronized source (SSRC) ID in theappropriate RTP field. Retransmitted data will use the same SSRC ID asthe originally sent data. A timestamp in each packet of audio data canbe the playback time for that packet according to the leader's clock andeach follower can use its clock offset estimate to determine theappropriate time to play each back to maintain time-synchronization withthe leader device's playback.

In certain implementations, because individual content frames may be toolarge to fit in a single packet, such individual content frames can besplit into multiple packets. In such approaches, the first 4 bytes ofeach packet can be a 16-bit frame ID and a 16-bit packet index, wherethe first packet in a given frame has an index of 0. Such index valuescan be in network byte order. The last packet in a frame can beindicated by setting a marker flag in an associated RTP header.

Follower devices (e.g., the follower devices 150 and 160) can sendnegative acknowledgements (NACKs) for missing packets (e.g., to theleader device 130) as soon as a missing packet is detected by thefollower device (e.g., due to a sequence number gap). In order to limitbandwidth overhead associated with transmission of NACKs, NACKs may besent no more frequently than, in an example implementation, once every10 ms. In such an approach, if a NACK was sent in the past 10 ms, thecorresponding follower device may wait until 10 ms after when theprevious NACK was sent before sending another NACK. The NACK packetformat can be as defined in RFC 4585.

In an implementation, a follower device of the system 100 may not sendNACKs for packets that would expire before a response from an associatedleader device is expected to arrive (e.g., based on a current RTTestimate). The expiry time for missing packets can be estimated as theexpiry time for the next received packet. Also, the leader devices 130,140 can be configured to not resend expired packets.

In such approaches, each sent NACK can have an associated timeout periodfor the NACKed packets to be resent, which can be determined as <RTTestimate>+<maximum jitter>. If a packet is still missing after thetimeout period expires, it can be NACKed again as long as it has notexpired (and will not expire before a response is expected to bereceived).

When a frame contains multiple packets, all packets in the frame can beexpected to arrive within a certain interval (e.g., 10 ms). If somepackets in a frame have not arrived after the expected interval (pluslatency jitter) has elapsed, the missing packets can be NACKed. Also, ifan inter-frame interval can be estimated, a NACK will be sent for thenext packet after the last packet of the frame. The NACK check for thenext packet can be timed to be (inter-frame interval+latency jitter).

In addition to authentication and key exchange, as discussed above, aTLS/TCP control channel (control channel) between a leader device andassociated follower devices in the system 100 can be used by a leaderdevice to send various commands corresponding with multizone (group)media playback to its associated (playback group) follower devices. Suchcommands can include start of media stream commands, pause/resumecommands (which can include the leader device's timestamp at which topause or resume, so that the followers can pause and resume in sync),end of media stream commands (which can include a sequence number andtimestamp of a final media data frame), and/or volume control commandsfor the group playback. In other implementations, other commands can beused.

In the system 100, the follower devices (e.g., the follower devices 150,160) can use the control channel to send information to theircorresponding leader device (e.g., the leader device 130). Suchinformation, for a given follower device, can include volume information(e.g., for determining volume adjustments on the given playback devicein response to playback group volume adjustments made on the leaderdevice), pause/resume/next/previous/stop notifications (e.g., if a userpresses a button on the give follower device), and leaving the stream(leaving playback group) notifications (e.g., if the follower devicereceives a local (single device) cast launch request, or a group castlaunch request from a different group).

A multizone manager of each playback device (such as shown in FIG. 2 anddiscussed in further detail below) can provide a mechanism for a senderapplication (e.g., on a media source device, such as the user devices110 and 120) to control individual device volume for each casting groupmember whenever the group is in a launched (e.g., casting media) state.This can be done via a transport namespace (e.g., a multizonenamespace).

For instance, when a playback group (e.g., a group media cast) islaunched, the multizone manager can provide (implement) a group volumecontrol mechanism. This volume control mechanism can allow sender apps(on a media source device) to control the volume of a group media castin a coordinated fashion. For instance, a group volume reported to thesender app can be an average of the individual device volumes. If thevolume setting of an individual playback device (leader or follower)changes (e.g., due to a volume control button press on the device, or byusing a device-specific volume change application program interface(API)), the group volume can be adjusted (e.g., by respective multizonemanagers) accordingly, such as proportionally or by a correspondingamount.

For example, if a user increases a casting group's volume (by 10%, forexample), such as from a sender app on a media source device, eachplayback device (e.g., leader and follower devices) in the associatedplayback group can increase its volume by that same amount (10%). Insuch an approach, if an individual device's volume would increase toover 100%, the volume of that device can be capped at 100% (which canthen be reflected in the group volume discussed above).

If a user decreases the group volume, there can be a threshold (e.g.,10% of total possible volume for a given playback device) where thegroup volume behavior changes. For instance, if all playback devicevolumes are above the threshold, then each device volume may simply bedecreased by the same amount as the user decrease (e.g., on the senderapp). However, if a given playback device's volume is at or below thethreshold, then the behavior may change, so that devices with highervolumes decrease their volume faster than devices that are already quiet(e.g., at volume settings below the threshold). This can be done bytaking the entire requested volume change (e.g., the total change acrossall group members to make the desired change to the average volume) anddividing it between devices proportional to their individual devicevolumes. For example, if one device was at 10% and the other was at 90%(group volume=50%) and the user requests a group volume change to 40%,then the total change is 20% (10% times 2 devices), of which 2% appliesto the quiet device (which goes to 8%) and 18% applies to the louddevice (goes to 72%) resulting in a new average (group) volume of 40%.

When decreasing the playback group volume, if no playback devices arecurrently at or below the (low-volume) threshold, but the decrease wouldresult in at least one device crossing the threshold, then the decreasecan be divided evenly among the devices until one device hits thethreshold. The remaining decrease can then be applied proportionatelyaccording to the below-threshold volume adjustment approach discussedabove.

A casting group can be considered to be muted, as a whole, if and onlyif all of its members are muted. In certain implementations, a user maychoose to mute/unmute an entire playback group, in which case all of itsmembers will be muted/unmuted together (at a same time). To implementsuch mute/unmute functions, the multizone namespace can provide anapplication program interface (API) that is configured to mute/unmuteindividual group members and/or mute/unmute a playback group as a whole.

In certain implementations, the system 100 can be used to implement amultichannel configuration. For instance, in some implementation, a usermay configure individual group members of a playback group to play onlya single channel (e.g., left channel or right channel) of media that isbeing streamed. Such multichannel configuration can be done on aper-playback-group basis. For example, if a given playback device is amember of two playback groups, the given playback device could beconfigured to play only a left audio channel when a first playback groupis playing media, and only play a right audio channel when a secondplayback group is playing media. In such implementations, when afollower device connects to a group leader, the follower device can sendinformation on its channel (multichannel) configuration to the leaderdevice. The leader device may be configured to then decide whether toonly send the necessary channel(s) to each follower device (e.g., toreduce network bandwidth usage). In any case, such implementations, eachplayback device may only playback the desired channel(s) according totheir respective multichannel configurations, where such playback can betime-synchronized using the approaches described herein.

FIG. 2 is a diagram illustrating an example implementation of the userdevice 110, the leader device 130 and the follower device 150 of thesystem 100 of FIG. 1, and communication (e.g., data networkcommunication) between those components for multizone media streaming,according to an implementation. As noted above, the leader device 130can be determined dynamically and elected from a group of media playbackdevices within a media casting group (playback group). Other componentsand elements than those shown in FIG. 2 can be included, or some of theillustrated components can be eliminated in certain implementations.

The devices of FIG. 2 may operate as follows. The playback devices(e.g., the leader device 130 and the follower device 150) can start upand start their respective media casting service. As a part of thisstartup, each playback device can create and initialize an instance of arespective multizone manager 212 and 242, including creating a time(clock) synchronization service. Each playback device can then comeonline and send out a service query, and announce its own castingservices (e.g., in a respective service query), indicating which casting(playback) groups it is a member of (e.g., using UUIDs). Responses tothe queries can be received and, from those responses, each playbackdevice can determine which other playback devices on the network aremembers of the same playback groups that it is a member of.

For each playback group that a given playback device is a member of, thegiven playback device (e.g., in cooperation with other playback devicesin each playback group) can then determine which playback device shouldbe the group leader for that group (based on the leader qualityinformation, such as the leadership metrics discussed above, containedin corresponding SRV and/or TXT records). In FIG. 2, the playback device130 (as in FIG. 1) is determined to be the leader device and theplayback device 150 is determined to be a follower device. Though only asingle follower device is shown in FIG. 2, it will be appreciated thatother follower devices can be included in the arrangement shown in FIG.2 (such as in the system 100 in FIG. 1) and can operate in similarfashion as the follower device 150.

In this example, the follower device 150 can then create a followergroup instance service (follower group) 236. The follower group 236 cancreate a control socket (e.g., a TCP/TLS connection) 238 to a leadergroup 216 instance of the leader device 130, and create a time syncrequester 234, which can begin sending time sync request packets to theleader's time sync responder 214.

After being identified as the leader playback device, the leader device130 can create the leader group instance 216 and begin accepting controlsocket connections for the corresponding playback group, such as fromthe follower device 150's control socket 238. The leader device 130 canalso create and announce a casting service for the group (e.g., using anmDNS broadcast message). As noted above, the SRV record for the leaderdevice 130 can indicate a port on the device (e.g., a virtual castingdevice port) that is specific to the group.

Casting media to a playback (casting) group using the arrangement shownin FIG. 2 can be performed as follows. A user can open a media castingapp on the user device 110 (which could be a handheld device, alaptop/computer, or otherwise). The media casting app can send out aservice query. Service responses (announcements) can then come back inresponse to the query, including the casting service for the group. Theuser can then select the group as a casting target. In response to theselection, a transport connection can be set up to a group-specific port(e.g., to a cast receiver 204 via a cast connection 202). Note that sucha transport connection can also be used for controlling a singleplayback device casting session (e.g., for single device, non-groupcasting).

The cast receiver 204 can then start a content application 206. Once thecontent application 206 is started, the multizone manager 212 of theleader device 130 can receive an “app started” notification from thecast receiver 204. By checking the port that the app was started from,the multizone manager 212 can determine that the content application 206was launched to cast media to the playback group for which the playbackdevice 130 is the leader.

The multizone manager 212 can then tell the leader group instance 216that the content application 206 is being launched. For instance, themultizone manager 212 can send a launch message to all connectedfollower devices, including the follower device 150, which can thenincrease their time (clock) sync request rate, such as described herein.The content application 206 can then open an audio output stream, whichcan be provided to a content streamer 220 and a synchronized audiooutput 222 of a local streamer service 218. For example, a call tocreate an output pipeline can be intercepted by the multizone manager212, which can then be provided to the local streamer 218 by themultizone manager 212. The content application 206 can also configurethe local streamer 218 for media playback. The multizone manager 212 canthen tell the leader group instance 216 to send the audio configurationinformation to the follower device 150 (and any other follower devicesof the leader device 130's casting group).

The content application 206 can then begin streaming media data, whichcan be obtained, by the content application 206 from, e.g., theInternet, the user device 110, or any other appropriate media datasource. The local streamer 218, in this example, can timestamp eachbuffer of audio data to play one second in the future or 1 second aheadin the audio stream (based on the leader device 130's clock), pass thetimestamped buffers to the local synchronized audio output 222, and alsopass the timestamped buffers to the content streamer instance 220 tosend to follower devices (e.g., follower device 150, etc.). The followergroup 236's content receiver 230 can receive audio packets (as sub-partsof the timestamped audio buffers) and assemble them into the completeaudio data buffers, requesting missing data where necessary. Each audiobuffer's timestamp is adjusted to the local clock time based on theestimated clock offset from the time sync requester 234. The contentreceiver can then pass the audio buffer data to its synchronized audiooutput 242. The synchronized audio output instances 222 and 242 ensurethat each audio buffer is played out (e.g., by the respective audiooutput pipelines 224 and 234) at the time indicated by the audiobuffer's timestamp (e.g., based on the buffer timestamp and, for thefollower device, its estimated clock offset).

In other implementations, the leader device 130 can attempt to furtherread-ahead, e.g., up to 5 seconds into a stream being played back. Incertain implementations, when such a media cast is made to a predefinedplayback group, a 500 ms playback delay can be used to allow playback(follower) devices to buffer audio data. In other implementations, suchas “groups-on-demand”, as described herein, the leader device can startplayback immediately upon receiving a casting requests (e.g., withouttimestamping buffers in the future). Since the buffer read-ahead islonger in such approaches (e.g., up to 5 seconds), such multizonecasting systems can be more tolerant of temporary network failures thatcan cause breaks or drop outs in playback, because each group member canhave up to 5 seconds of data buffered for media that is being streamedto an associated playback group.

In such approaches, the speed at which data is sent to followers can berate-limited. If data is sent too fast, the bandwidth used may be higherthan an associated network connection can support, which can lead topacket loss and packets being resent, further impacting bandwidth. In anexample implementation, the data rate can be limited to 1.5× theplayback rate for initial packets (i.e., not resent), and 2× theplayback rate for resent packets.

When pausing/resuming playback in such approaches, a control message canbe sent to follower devices with an expected timestamp of thepause/resume. Each follower device can then pause as soon as it gets thepause message, and resume playback (in response to the resume message)at the appropriate timestamp. In such implementations, the leader device130 must keep track of how long the playback was paused, and includethis interval (paused time period) in the resume message to its followerdevices. The follower devices can then update their buffered datatimestamps accordingly, so that the resumed playback is stilltime-synchronized.

In group-on-demand implementations, if a media cast is initially castedto a single playback device, an audio playback delay of zero can beimplemented (e.g., instead of the 500 ms audio playback delay discussedabove that can be used for predefined group casts). Such use of a zerodelay may not result in any audio quality issues as, for a cast that isinitially to a single playback devices, there are (at least initially)no followers for which playback needs to be time-synchronized when thecast is started. The predefined group cast audio delay is to allow allgroup members to start playback at the start of the cast.

In the techniques described herein, the intent of time (clock)synchronization, e.g., between the leader device 130 and the followerdevice 150, is to measure a RTT between two devices, and use thatmeasure of RTT to calculate a clock offset. For instance, a requestercan send a time sync request packet to a responder with an initial sendtime (time_1). The responder can receive the packet, add its currenttime (time_2) to the packet and then send the packet back to therequester as a response to the time sync request. The requester, uponreceiving the response, can then get its current time (e.g., a time theresponse is received, referred to below as (now)).

If transmission latency in both directions of the round trip is thesame, it could be determined that time_2−time_1=−offset+latency, andnow−time_2=offset+latency. Therefore, a clock offset can be estimated as((now−time_2)−(time_2−time_1))/2.

However, in many instances, transmission latency is not the same in bothround-trip directions. For example, in a WiFi network, transmissionlatency in each direction can be randomly distributed. This means thatfor a given RTT, the offset estimate can be incorrect by up to RTT/2. Itwill be noted that the calculated latency can also include variationsdue to process scheduling (in the playback devices) and clock precision.Such effects, however, can be relatively small (e.g., on the order oftens of microseconds), as compared to directional RTT variation due toWiFi.

In order to account for the variation in transmission latency, such asin the approaches described herein, multiple samples can be used toimprove clock offset estimates. In an example implementation, the errorof a given sample can be initially estimated by (RTT/2). A simpleweighted average of the samples can then be used, where theweight=1/error{circumflex over ( )}2=1/RTT{circumflex over ( )}2. Thisapproach can be used initially to quickly determine an accurate clockoffset estimate (even with 1 sample, if the RTT is low). The error ofthe weighted average can be approximated by the weighted sum of thesample errors.

However, in some implementations, using the weighted average may notprovide an estimate of clock drift, and can introduce a consistent biasif one clock is faster than the other (e.g., where the bias is equal to½ the clock drift over the averaging period). Accordingly, as describedherein, a moving weighted linear regression can be used to accuratelyestimate a clock offset and also account for any clock drift rates. Inexample implementations, it may be more accurate to use a moving linearregression window (with a relatively long window period, e.g., on theorder of 5 to 10 minutes), so as to account for any changes in clockdrift rate over time.

In the example of FIG. 2, the multizone manager 232 of the followerdevice 150 can maintain both a moving average and a moving linearregression estimate of clock offset, and produce a final clock offsetestimate as a weighted average of the two results based on the estimatederrors from each. Also, the moving average estimate weight can decreaselinearly to 0 after an initial period has passed. An empirical exampleof using such an approach for clock offset estimation is provided below.

In this empirical example two devices, a “leader” device (leader device130) and a “follower” device (follower device 150), such as shown inFIG. 2, are described. Other sets of leader and follower devices canalso be time-synchronized using such approaches. Also, in this example,the follower device 150 is attempting to estimate an offset between itssystem clock and the leader device 130's system clock. The two devicesare communicating over a WiFi network.

Initially, in this example, the leader device 130's clock is 1000000(microseconds) and the follower device 150's clock is 2000000. Theleader device 130's clock will have (has) a 20 ppm drift, so in 1 secondit will increase by 1000020. The follower device 150's clock has noappreciable drift in this example. Note that the follower device 150, inthis example, has no way to determine the leader's exact clock value atany given time, or to determine the drift rate of either clock.

In this empirical example, the follower device 150 sends out an initialrequest (e.g., time sync request) to the leader device 130, containingits current clock value (2000000). This request takes 50000 microsecondsto arrive at the leader device 130. The leader device 130 sends aresponse back to the follower device 150 containing its current clockvalue (1050001) and the follower device 150's clock value from therequest. The response takes 10000 microseconds to return to the followerdevice 150. When the follower device 150 receives the response, it getsthe current time (2060000). The follower device 150 can then calculatethe roundtrip time (2060000−2000000=60000) and the offset estimate((2060000−1050001)−(1050000−2000000))/2=980000 microseconds. Thefollower device 150 now has one sample (time=2060000, offset=980000,weight=1/RTT{circumflex over ( )}2=2.78*10⁻¹⁰°). This sample is added toa weighted linear regression, and to a weighted average. In thisexample, an offset estimate based on the linear regression and/or theweighted average cannot yet be calculated yet, because the linearregression requires at least 3 samples to accurately estimate the error,and the weighted average requires at least 2 samples to accuratelyestimate the error.

Continuing with the foregoing example, the follower device 150 can thenmake another time sync request when its clock reaches 2100000. Thistime, the request takes 5 ms to reach the leader (at 1105002 on theleader device 130's clock), and the response takes 5 ms to return (at2110000 on the follower device 150's clock). The RTT is 10000 and theoffset estimate is 999998. The follower device can then add anothersample (time=2110000, offset=999998, weight=1.0*10⁻⁸) to the linearregression and the weighted average.

At this point in this example, the offset and error can be estimatedusing the weighted average. The weighted average is(980000*2.78*10⁻¹⁰+999998*1.0*10⁻⁸)/(2.78*10⁻¹⁰+1.0*10⁻⁸)=999458microseconds. The weighted variance is(2.78*10−10*(980000−999458)2+1.0*10−8*(999998−−999458)²)/(2.78*10⁻¹⁰+1.0*10⁻⁸)=10516521,and the standard error is 3243. The linear regression cannot yet be usedto make an estimate as only two RTT samples have been obtained.Therefore, the current estimate of the clock offset is 999998microseconds, with an error estimate of 3243 microseconds (based on thetwo-sample weighted average).

Again continuing with the above example, the follower device 150 canmake a third time sync request when its clock reaches 2200000. The thirdrequest, in this example, takes 10 ms to reach the leader device 130 (at1210004 on the leader device 130's clock) and 20 ms to return to thefollower (at 2230000 on the follower device 150's clock). The RTT is30000 and the offset estimate is 1004996. The follower can now addanother (third) sample (time=2230000, offset=1004996, weight=1.11*10⁻⁹)to the linear regression and the weighted average.

The weighted average is now(980000*2.78*10⁻¹⁰+999998*1.0*10⁻⁸+1004996*1.11*10⁻⁹)/(2.78*10⁻¹⁰+1.0*10⁻⁸+1.11*10⁻⁹)=999997microseconds. The weighted variance is(2.78*10⁻¹⁰*(980000−999997)²+1.0*10⁻⁸*(999998999997)²+1.11*10⁻⁹*(1004996999997)²)/(2.78*10⁻¹⁰+1.0*10⁻⁸+1.11*10⁻⁹)=12197537, and the standarderror is 3492.

As three samples have been obtained, the weighted linear regression cannow be calculated, where the x values are the times that the sampleswere taken, and the y values are the offsets for each sample. Theweighted mean of x is 2120476, and the weighted mean of y is 999997. Theweighted covariance issum(weight[i]*(x[i]x_mean)*(y[i]y_mean))/sum(weight[i])=82879170. The xvariance is sum(weight[i]*(x[i]x_mean)²)/sum(weight[i])=1354866562. They variance is 12197537. The slope is then thecovariance/x_variance=0.06117. The current x difference is (current timex_mean)=109524, and the estimated offset is y_mean+slope*x_diff=1006697.

The residual sum of squares iscovariance²*sum(weight[i])/x_variance=0.05773, and the mean squarederror is y_variance−rss=0.08117. The slope variance ismse/x_variance=0.0052608. The intercept variance isslope_variance*x_variance=7127697. The calculated y error is thensqrt(intercept_variance+slope_variance*x_diff²)=8381. The 98% confidenceinterval of the offset estimate can then be calculated by multiplying bythe 99th quantile of a student's t-distribution with 1 degree of freedom(31.82), giving a final error estimate for the linear regression of266670 microseconds. A 98% confidence interval was chosen, in thisexample, because it produced good time-synchronization results in theassociated empirical testing.

The final offset estimate and error can then be calculated as a weightedaverage of the estimate from the weighted average and the estimate fromthe linear regression. The weight for the linear regression estimate is1/(linear_error²)=1.406*10−11. In this example, the weight for theweighted average estimate is (age_weight/avg_error²), where age_weightdecreases linearly from 1 at the start of time synchronization to 0after 5 minutes. In other implementations, other time periods (otherthan 5 minutes) can be used during which age_weight decreases to 0. Inthe above example, since 230000 microseconds have passed since the startof estimation, the age_weight is 0.9992, the weight for the weightedaverage estimate is 8.194*10⁻⁸. Therefore, the final combined offsetestimate is 999998 microseconds, with an error estimate of 3493microseconds.

The follower device 150 can then continue to make time sync requests andadd more samples to the weighted average and the linear regression. Astime goes on, the linear regression estimate will become much moreaccurate (the variance decreases, and the t-distribution multiplierdrops quickly as the number of samples increases). The weighted averageestimate may eventually become inaccurate due to the clock drift. Forexample, a last 5 minutes of samples are used to compute the weightedaverage, the calculated offset will be incorrect by 3000 microseconds(since the clock drifts by 20 microseconds per second).

Note that in this example, time sync requests were made every 100 ms. Inother implementations, the request frequency can vary (e.g., at runtime)based on a current error estimate, and the system (e.g., system 100)state. If synchronized time will be needed soon (e.g., time-synchronizedaudio playback for a playback group is about to start), the time syncrequest frequency can be increased to improve the time offset estimate.

In other implementations, instead of determining clock offset/error byadding (sample, weight) to the linear regression and moving average,(sample−latency, weight) and (sample+latency, weight) can be added tothe linear regression and moving average, where latency=RTT/2. Such anapproach can improve the accuracy of the error estimate, as well asreduce the time to determine error with enough precision to allow fortime-synchronized playback. In such an approach, audio playback canbegin with an error estimate that is sufficiently accurate to preventperceptible audio distortions that may occur when the clock offset erroris corrected (converges) using other approaches. Mathematically, thisapproach can be implemented using only two measurements (as describedabove) to start using the linear regression for error estimation, andone measurement for using the moving average. In certainimplementations, however, additional measurements can be made prior toestimating clock offset/error. For, instance, in an implementation, atleast 2 measurements can be taken before using the moving average, and15 measurements can be taken before starting to use the linearregression. In other implementations, other respective numbers ofsamples can be taken before using the moving average or the linearregression to estimate error (offset).

Different speakers/audio output devices can have different inherentoutput delays, e.g., after the audio samples have been pushed tocorresponding audio pipeline hardware, the delay until the correspondingsound is produced can vary significantly between different speakers. Thedifference can be up to a few hundred milliseconds.

In order to improve synchronization between different speakers in amultizone casting (playback) group, the inherent output delay of eachspeaker can be determined and compensated for by adjusting the softwareoutput of samples so that the actual sounds are produced simultaneously.Note that, in such an approach, the absolute delay of each speaker doesnot need to be determined, just the delay of each speaker relative to acommon reference point, which can be determined, for example, using theexample implementation described below.

In this example implementation, a user's handheld device can be used asa common reference point. For each speaker (e.g., of playback devices ofa given playback group), the user can hold the handheld device next tothe speaker and run a calibration application (e.g., by pressing a“calibrate” button). The calibration application can be configured tohave both the cast (playback) device and the user's handheld device playa sound (same sound) at known, common timestamps. The handheld devicewill record the played sounds from both devices and use the timedifference between them to determine the actual output latency of thespeaker system (relative to the output latency of the handheld device).

Such playback device audio (speaker) latency calibration canaccomplished using the following example approach. In this example, acasting device for which audio latency calibration is being performedcan achieve time synchronization with the internal clock on a handhelddevice being used for audio latency calibration. This timesynchronization can be achieved using the time synchronizationapproaches described herein. After time synchronization is achieved, thehandheld device can determine an appropriate volume level to use whenplaying the sound. For instance, in order for the calibration to workproperly, a volume of the sound received at the handheld device from thecast (playback) device should be within, e.g., 12 dB of a volume of thesound from the handheld device. To achieve this, the handheld device canplay the sound initially while recording, and then instruct the speakerto play the sound while recording. If needed (e.g., if the volume of thesound that the handheld device receives from itself is >12 dB away fromthe received volume from the speaker), the handheld device can adjustits output volume and repeat the above process.

Once time synchronization and acceptable volume levels are determined,the handheld device can determine (get, obtain, etc.) its currenttimestamp N. The handheld device can then instruct the cast (playback)device to play the predefined sound at a given timestamp Tc=N+Dc (whereDc is a delay value, e.g., Dc can be initially be 100 ms and change overiterations of the calibration process) relative to the handheld device'sinternal clock. This process can use the approaches used in multizonetime-synchronized media streaming to play the sound at a given, remote(remote to the handheld device) timestamp on the cast (playback) device.The handheld device can then begin recording (at an appropriate time) tocapture playback of the sound by the playback device being calibrated.Further, the handheld device can play the sound at a timestamp Th=N+Dh(Dh=e.g., 100 ms) close to the time that the playback device is supposedto play the sound. The actual time (Ta) that the sound is played by thehandheld device can be determined using getTimestamp function of thehandheld device.

In this example, the sounds from both the handheld device and theplayback device will be recorded, where recording can stop after enoughtime has passed that both sounds should have completed playing, e.g.,Th+300 ms. A time delta (difference) between the two recorded sounds canthen be determined using signal processing. The value of this differencecan, for this first iteration, be determined as an absolute value (e.g.,as it may not be known which device, handheld device or playback device,played the sound first). Therefore, the measurement must be repeated (atleast once) with modified timestamps to get the sign of the difference.For instance the above process can repeat from the point where thehandheld device obtains its current timestamp, but changing thetimestamps the handheld (Th) and playback device (Tc) play the sound,such that the playback device should play the sound 20 ms earlier thanthe previous iteration (e.g., Dc=80 ms in this example).

After the first two iterations are complete, if the time delta(difference) increased between the first two iterations, then the signof the difference can be determined to be negative, otherwise thedifference is positive. The delay for the playback device/speakers beingcalibrated can then be determined by (delta (Tc−Ta)). This value canthen be sent to the playback device as the calibrated audio delay forthe given speaker, which can be used by the playback device to maintainaudio playback synchronization between playback devices for acorresponding playback (media casting) group. The particular values,times and number of iterations used for the foregoing audio latencycalibration process can vary and will depend, at least in part, on thespecific implementation.

FIG. 3 is a flowchart illustrating a method 300 for time-synchronizedmedia playback to a media playback group including a plurality ofplayback devices. The method 300 shown in FIG. 3, as well as the methodsof FIGS. 4-9, can be implemented in the system 100 of FIG. 1 and/orusing the leader device 130 and the follower device 150 illustrated inFIG. 2 (and other follower devices). Also, the methods of FIGS. 3-9 canbe implemented using the approaches discussed herein, though thespecific details of those approaches may not be repeated with referenceto the flowcharts of FIGS. 3-9. Further, it will be appreciated that themethods of FIGS. 3-9 can be implemented in media playback systems havingconfigurations other than those illustrated in FIGS. 1 and 2.

As shown in FIG. 3, the method 300 can include, at block 310, connectinga first media playback device with a data network, where the first mediaplayback device is operationally associated with a (first) mediaplayback group. At block 320, the method 300 can include connecting asecond media playback device with the data network, where the secondmedia playback device is operationally associated with the mediaplayback group. Connecting the first media playback device and thesecond media playback device with the data network can include the firstmedia playback device and the second media playback device sendingrespective broadcast messages on the data network announcing theirmembership in the media playback group and including respective queriesfor other devices connected with the data network that are members ofthe media playback group. As described herein, the first media playbackdevice and the second media playback device can also be operativelyassociated with other media playback groups (e.g., as leader devicesand/or follower devices).

At block 330, the method 300 can include designating one of the firstmedia playback device and the second media playback device as a leaderplayback device of the media playback group. In the method 300, the oneof the first media playback device and the second media playback devicenot designated as the leader playback device in the method 300, isdesignated as a follower playback device of the media playback group. Asdescribed herein, the designation of a leader playback device can bebased on respective leadership metrics for the first media playbackdevice and the second media playback device, the leadership metricsbeing based on respective attributes for network connections (e.g.,network connection quality) of the first media playback device and thesecond media playback device. In other approaches, the designation ofthe leader device and the follower device for the first media playbackdevice and the second media playback device can be preconfigured.

At block 340, the method 300 can include determining a clock offsetbetween the leader playback device and the follower playback device,where the clock offset can be determined using the approaches describedherein (e.g., by calculating a weighted average and/or a linearregression based on RTTs). At block 350, the method 300 can includereceiving, at the leader playback device, a media stream for playback bythe media playback group.

At block 360, the method 300 can include playing the media stream by theleader playback device. At block 370, the method 300 can includeproviding, by the leader playback device, the media stream to thefollower playback device, which can include providing the media streamto the follower playback device in a sequence of timestamped datapackets. At block 380, the method 300 can include playing, by thefollower playback device, the media stream in synchronization with theleader playback device based on the clock offset (and respectivetimestamps of the packets). The method 300 can also include, buffering,by the leader playback device and the follower playback device,respective portions of the media stream, such as described herein.

FIG. 4 is a flowchart illustrating a method 400 for designating a leaderdevice of a media playback group. In an implementation, the method 400can be implemented at block 330 of the method 300.

As shown in FIG. 4, the method 400 can include, at block 410,determining a leadership metric for the first media playback device and,at block 420, determining a leadership metric for the second mediaplayback device. At block 430, the method 400 can include designatingone of the first media playback device and the second media playbackdevice as the leader playback device based on a comparison of theleadership metric for the first media playback device and the leadershipmetric for the second media playback device. For instance, the playbackdevice with a higher (greater, larger, etc.) effective_SNR value can bedesignated as the leader device.

The determination at block 430 can include determining a leader betweenplayback devices with equal leadership metrics, such as by comparing IPaddresses of the playback devices and designating a leader device basedon that comparison. In the method 400, the leadership metric for thefirst media playback device, at block 410, can be based on one or moreattributes of a network connection of the first media playback with thedata network. Likewise, the leadership metric for the second mediaplayback device, at block 420, can be based on one or more attributes ofa network connection of the second media playback with the data network.

FIG. 5 is a flowchart illustrating a method 500 for determining a clockoffset between a leader device and a follower device of a media playbackgroup. In an implementation, the clock offset can be determined byiteratively performing (e.g., prior to, and during media playback) theoperations of the method 500. The method 500 can be implemented usingthe approaches described herein (e.g., including calculating a weightedaverage and/or a linear regression).

At block 510, the method 500 can include sending, by the followerplayback device, a synchronization request including a timestampedpacket to the leader playback device, the timestamped packet indicatinga time of a clock of the follower playback device. At block 520, themethod 500 can include receiving, by the leader playback device, thesynchronization request from the follower playback device. At block 530,the method 500 can include sending, by the leader playback device inresponse to the synchronization request, a synchronization responseincluding an indication a time of a clock of the leader playback deviceand the time of the clock of the follower playback device included inthe synchronization request. At block 540, the method 500 can includedetermining, by the follower device based on the synchronizationresponse, a round-trip-time (RTT) of the synchronization request andsynchronization response and the clock offset based on the RTT. In themethod 500, determining the RTT can include calculating at least one ofa weighted moving average and a linear regression based on two or more(iterative) synchronization request and synchronization responsesequences.

FIG. 6 is a flowchart illustrating a method 600 for adding a playbackdevice to a media playback group that is currently playing media, suchas adding a third playback device to the media playback group of themethod of FIG. 3. For instance, the follower playback device of themethod 300 can be a first follower playback device.

At block 610, the method 600, when implemented in conjunction with themethod 300, can include connecting a third media playback device withthe data network, where the third media playback device is operationallyassociated with the media playback group. At block 620, the method 600can include designating the third media playback device as a secondfollower playback device. At block 630, the method 600 can includedetermining a clock offset between the leader playback device and thesecond follower playback device, such as using the approaches describedherein. The method 600 can further include, at block 640, providing, bythe leader playback device, the media stream to the second followerplayback device and, at block 650, playing, by the second followerplayback device, the media stream in synchronization with the leaderplayback device based on the clock offset between the leader playbackdevice and the second follower playback device.

FIG. 7 is a flowchart illustrating a method 700 for a playback device,such as the follower playback device of the method 300, leaving a mediaplayback group. At block 710, the method 700 can include (e.g., whenimplemented in conjunction with the method 300), sending, by thefollower playback device to the leader playback device, an indicationthat the follower playback device is leaving the media playback group.At block 720, the method 700 can include, in response to the indication,discontinuing, by the leader playback device, providing the media streamto the follower device and updating, by the leader playback device,membership information for the media playback group to remove thefollower playback device.

FIG. 8 is a flowchart illustrating a method 800 for changing a mediastream that is being played by a media playback group. As with themethods 600 and 700, the method 800 can be implemented in conjunctionwith the method 300 of FIG. 3, where the media stream of the method 300is a first media stream.

At block 810, the method 800 can include receiving, at the leaderplayback device, a request to playback a second media stream by themedia playback group. In response to the request to playback the secondmedia stream, the method 800 can include, at block 820, stoppingplayback of the first media stream by the leader playback device and thefollower playback device. After stopping playback of the first mediastream at block 820, the method 800 can include, at block 830, playingthe second media stream by the leader playback device and, at block 840,providing, by the leader playback device, the second media stream to thefollower playback device. At block 850, the method 800 can includeplaying, by the follower playback device, the second media stream insynchronization with the leader playback device based on the clockoffset.

FIG. 9 is a flowchart illustrating a method 900 for determining an audiooutput delay of a media playback device. The method 900 can beimplemented using the approaches for determining audio output delaydescribed herein.

At block 910, the method 900 can include determining a volume of a soundto be played on (by) a reference device (e.g., a handheld device, suchas a smartphone), where the sound is used to determine an audio outputdelay of the playback device. At block 920, the method 900 can includeiteratively playing the sound with the playback device and the referencedevice while varying a playback delay (playback offset) for eachiteration. Also, at block 920, the reference device can record playbackof the sound from both the playback device and the reference device foreach iteration. At block 930, the method 900 can include determining atime delta (audio playback delay) based on at least two iterations ofplayback and recording. In an implementation, playing, by the followerplayback device, the media stream in synchronization with the leaderplayback device can include playing, by the follower playback device,the media stream in synchronization with the leader playback devicebased on the clock offset and the output delay of the follower playbackdevice determined using the method 900.

In a general aspect, a system for media playback can include a mediacasting device configured to broadcast a media stream to a data networkfor playback by a media playback group; a first media playback deviceconfigured to receive the media stream, the first media playback devicebeing a member of the media playback group; and a second media playbackdevice configured to receive the media stream, the second media playbackdevice being a member of the media playback group. The first mediaplayback device and the second media playback device can be collectivelyconfigured to designate one of the first media playback device and thesecond media playback device as a leader playback device of the mediaplayback group. The one of the first media playback device and thesecond media playback device not designated as the leader playbackdevice can be designated as a follower playback device of the mediaplayback group. The first media playback device and the second mediaplayback device can be further collectively configured to determine aclock offset between the leader playback device and the followerplayback device. The leader playback device can be configured to receivethe broadcast of the media stream from the data network; play the mediastream; and provide the media stream to the follower playback device.The follower playback device can be configured to play the media streamin synchronization with the leader playback device based on the clockoffset.

Implementations can include one or more of the following features. Forinstance, the first media playback device and the second media playbackdevice can each include a respective record indicating membership in themedia playback group. The media playback group can be a first mediaplayback group, and the respective record of the first media playbackdevice can further indicate membership in a second media playback group.

The system can include a third media playback device configured toreceive the media stream. The third media playback device can be amember of the media playback group. The third media playback device andthe leader playback device can be collectively configured to determine aclock offset between the leader playback device and the third playbackdevice. The leader playback device can be configured to provide themedia stream to the third media playback device. The third mediaplayback device can be configured to play the media stream insynchronization with the leader playback device based on the clockoffset between the leader playback device and the third playback device.

Designating one of the first media playback device and the second mediaplayback device as a leader playback device of the media playback groupcan include comparing a measure of quality of a data connection of thefirst media playback device with the data network and a measure ofquality of a data connection of the second media playback device withthe data network.

Each of the first media playback device and the second media playbackdevice can be configured to implement a broadcast service to broadcast amessage indicating membership in the media playback group. Thebroadcasted message can include a query requesting a response from mediaplayback devices that are connected to the data network and members ofthe media playback group.

The leader playback device providing the media stream to the followerplayback device can include providing the media stream to the followerplayback device in a sequence of timestamped data packets.

Playing, by the follower playback device, the media stream insynchronization with the leader playback device based on the clockoffset can include playing, by the follower playback device, the mediastream in synchronization with the leader playback device based on theclock offset and an output delay of the follower playback device. Theclock offset can be determined based on a round-trip-time (RTT) betweenthe leader playback device and the follower playback device.

In another general aspect, a method can include connecting a first mediaplayback device with a data network, the first media playback devicebeing operationally associated with a media playback group andconnecting a second media playback device with the data network, thesecond media playback device being operationally associated with themedia playback group. The method can further include designating one ofthe first media playback device and the second media playback device asa leader playback device of the media playback group, where the one ofthe first media playback device and the second media playback device notdesignated as the leader playback device can be designated as a followerplayback device of the media playback group. The method can also includedetermining a clock offset between the leader playback device and thefollower playback device; receiving, at the leader playback device, amedia stream for playback by the media playback group and playing themedia stream by the leader playback device. The method can still furtherinclude providing, by the leader playback device, the media stream tothe follower playback device and playing, by the follower playbackdevice, the media stream in synchronization with the leader playbackdevice based on the clock offset.

Implementations can include one or more of the following features. Forinstance, connecting the first media playback device with the datanetwork can include the first media playback device sending a broadcastmessage indicating the first media playback device's membership in themedia playback group. The broadcast message can include a queryrequesting a response from media playback devices that are connected tothe data network and operationally associated with the media playbackgroup. The media playback group can be a first media playback group andthe broadcast message can indicate the first media playback device'smembership in a second media playback group. Connecting the second mediaplayback device with the data network can include the second mediaplayback device sending a broadcast message indicating the second mediaplayback device's membership in the media playback group.

Designating one of the first media playback device and the second mediaplayback device as the leader playback device can include determining aleadership metric for the first media playback device; determining aleadership metric for the second media playback device; and designatingone of the first media playback device and the second media playbackdevice as the leader playback device based on a comparison of theleadership metric for the first media playback device and the leadershipmetric for the second media playback device. The leadership metric forthe first media playback device can be based on one or more attributesof a network connection of the first media playback with the datanetwork. The leadership metric for the second media playback device canbe based on one or more attributes of a network connection of the secondmedia playback with the data network.

Determining the clock offset between the leader playback device and thefollower playback device can include, iteratively: sending, by thefollower playback device, a synchronization request including atimestamped packet to the leader playback device, the timestamped packetindicating a time of a clock of the follower playback device; receiving,by the leader playback device, the synchronization request from thefollower playback device; sending, by the leader playback device inresponse to the synchronization request, a synchronization responseincluding an indication a time of a clock of the leader playback deviceand the time of the clock of the follower playback device included inthe synchronization request; and determining, by the follower devicebased on the synchronization response: a round-trip-time (RTT) of thesynchronization request and synchronization response; and the clockoffset based on the RTT. Determining the RTT can include calculating atleast one of a weighted moving average and a linear regression based ontwo or more synchronization responses.

Providing the media stream to the follower playback device can includeproviding the media stream to the follower playback device in a sequenceof timestamped data packets. The method can include buffering, by theleader playback device and the follower playback device, respectiveportions of the media stream.

The follower playback device can be a first follower playback device,and the method can include connecting a third media playback device withthe data network. The third media playback device can be operationallyassociated with the media playback group. The method can includedesignating the third media playback device as a second followerplayback device and determining a clock offset between the leaderplayback device and the second follower playback device. The method caninclude providing, by the leader playback device, the media stream tothe second follower playback device and, playing by the second followerplayback device, the media stream in synchronization with the leaderplayback device based on the clock offset between the leader playbackdevice and the second follower playback device.

The method can include sending, by the follower playback device to theleader playback device, an indication that the follower playback deviceis leaving the media playback group. In response to the indication, themethod can include discontinuing, by the leader playback device,providing the media stream to the follower device and updating, by theleader playback device, membership information for the media playbackgroup to remove the follower playback device.

Playing, by the follower playback device, the media stream insynchronization with the leader playback device based on the clockoffset can include playing, by the follower playback device, the mediastream in synchronization with the leader playback device based on theclock offset and an output delay of the follower playback device.

The media stream can be a first media stream, and the method can includereceiving, at the leader playback device, a request to playback a secondmedia stream by the media playback group. In response to the request toplayback the second media stream, the method can include stoppingplayback of the first media stream by the leader playback device and thefollower playback device. After stopping playback of the first mediastream, the method can include playing the second media stream by theleader playback device; providing, by the leader playback device, thesecond media stream to the follower playback device; and playing, by thefollower playback device, the second media stream in synchronizationwith the leader playback device based on the clock offset.

FIG. 10 shows an example of a generic computer device 1000 and a genericmobile computer device 1050, which may be used with the techniquesdescribed here. Computing device 1000 is intended to represent variousforms of digital computers, such as laptops, desktops, workstations,personal digital assistants, servers, blade servers, mainframes, andother appropriate computers. Computing device 1050 is intended torepresent various forms of mobile devices, such as personal digitalassistants, cellular telephones, smart phones, and other similarcomputing devices. The components shown here, their connections andrelationships, and their functions, are meant to be exemplary only, andare not meant to limit implementations of the inventions describedand/or claimed in this document.

Computing device 1000 includes a processor 1002, memory 1004, a storagedevice 1006, a high-speed interface 1008 connecting to memory 1004 andhigh-speed expansion ports 1010, and a low speed interface 1012connecting to low speed bus 1014 and storage device 1006. Each of thecomponents 1002, 1004, 1006, 1008, 1010, and 1012, are interconnectedusing various busses, and may be mounted on a common motherboard or inother manners as appropriate. The processor 1002 can processinstructions for execution within the computing device 1000, includinginstructions stored in the memory 1004 or on the storage device 1006 todisplay graphical information for a GUI on an external input/outputdevice, such as display 1016 coupled to high speed interface 1008. Inother implementations, multiple processors and/or multiple buses may beused, as appropriate, along with multiple memories and types of memory.Also, multiple computing devices 1000 may be connected, with each deviceproviding portions of the necessary operations (e.g., as a server bank,a group of blade servers, or a multi-processor system).

The memory 1004 stores information within the computing device 1000. Inone implementation, the memory 1004 is a volatile memory unit or units.In another implementation, the memory 1004 is a non-volatile memory unitor units. The memory 1004 may also be another form of computer-readablemedium, such as a magnetic or optical disk.

The storage device 1006 is capable of providing mass storage for thecomputing device 1000. In one implementation, the storage device 1006may be or contain a computer-readable medium, such as a floppy diskdevice, a hard disk device, an optical disk device, or a tape device, aflash memory or other similar solid state memory device, or an array ofdevices, including devices in a storage area network or otherconfigurations. A computer program product can be tangibly embodied inan information carrier. The computer program product may also containinstructions that, when executed, perform one or more methods, such asthose described above. The information carrier is a computer- ormachine-readable medium, such as the memory 1004, the storage device1006, or memory on processor 1002.

The high speed controller 1008 manages bandwidth-intensive operationsfor the computing device 1000, while the low speed controller 1012manages lower bandwidth-intensive operations. Such allocation offunctions is exemplary only. In one implementation, the high-speedcontroller 1008 is coupled to memory 1004, display 1016 (e.g., through agraphics processor or accelerator), and to high-speed expansion ports1010, which may accept various expansion cards (not shown). In theimplementation, low-speed controller 1012 is coupled to storage device1006 and low-speed expansion port 1014. The low-speed expansion port,which may include various communication ports (e.g., USB, Bluetooth,Ethernet, wireless Ethernet) may be coupled to one or more input/outputdevices, such as a keyboard, a pointing device, a scanner, or anetworking device such as a switch or router, e.g., through a networkadapter.

The computing device 1000 may be implemented in a number of differentforms, as shown in the figure. For example, it may be implemented as astandard server 1020, or multiple times in a group of such servers. Itmay also be implemented as part of a rack server system 1024. Inaddition, it may be implemented in a personal computer such as a laptopcomputer 1022. Alternatively, components from computing device 1000 maybe combined with other components in a mobile device (not shown), suchas device 1050. Each of such devices may contain one or more ofcomputing device 1000, 1050, and an entire system may be made up ofmultiple computing devices 1000, 1050 communicating with each other.

Computing device 1050 includes a processor 1052, memory 1064, aninput/output device such as a display 1054, a communication interface1066, and a transceiver 1068, among other components. The device 1050may also be provided with a storage device, such as a microdrive orother device, to provide additional storage. Each of the components1050, 1052, 1064, 1054, 1066, and 1068, are interconnected using variousbuses, and several of the components may be mounted on a commonmotherboard or in other manners as appropriate.

The processor 1052 can execute instructions within the computing device1050, including instructions stored in the memory 1064. The processormay be implemented as a chipset of chips that include separate andmultiple analog and digital processors. The processor may provide, forexample, for coordination of the other components of the device 1050,such as control of user interfaces, applications run by device 1050, andwireless communication by device 1050.

Processor 1052 may communicate with a user through control interface1058 and display interface 1056 coupled to a display 1054. The display1054 may be, for example, a TFT LCD (Thin-Film-Transistor Liquid CrystalDisplay) or an OLED (Organic Light Emitting Diode) display, or otherappropriate display technology. The display interface 1056 may compriseappropriate circuitry for driving the display 1054 to present graphicaland other information to a user. The control interface 1058 may receivecommands from a user and convert them for submission to the processor1052. In addition, an external interface 1062 may be provided incommunication with processor 1052, so as to enable near areacommunication of device 1050 with other devices. External interface 1062may provide, for example, for wired communication in someimplementations, or for wireless communication in other implementations,and multiple interfaces may also be used.

The memory 1064 stores information within the computing device 1050. Thememory 1064 can be implemented as one or more of a computer-readablemedium or media, a volatile memory unit or units, or a non-volatilememory unit or units. Expansion memory 1074 may also be provided andconnected to device 1050 through expansion interface 1072, which mayinclude, for example, a SIMM (Single In Line Memory Module) cardinterface. Such expansion memory 1074 may provide extra storage spacefor device 1050, or may also store applications or other information fordevice 1050. Specifically, expansion memory 1074 may includeinstructions to carry out or supplement the processes described above,and may include secure information also. Thus, for example, expansionmemory 1074 may be provided as a security module for device 1050, andmay be programmed with instructions that permit secure use of device1050. In addition, secure applications may be provided via the SIMMcards, along with additional information, such as placing identifyinginformation on the SIMM card in a non-hackable manner.

The memory may include, for example, flash memory and/or NVRAM memory,as discussed below. In one implementation, a computer program product istangibly embodied in an information carrier. The computer programproduct contains instructions that, when executed, perform one or moremethods, such as those described above. The information carrier is acomputer- or machine-readable medium, such as the memory 1064, expansionmemory 1074, or memory on processor 1052, that may be received, forexample, over transceiver 1068 or external interface 1062.

Device 1050 may communicate wirelessly through communication interface1066, which may include digital signal processing circuitry wherenecessary. Communication interface 1066 may provide for communicationsunder various modes or protocols, such as GSM voice calls, SMS, EMS, orMMS messaging, CDMA, TDMA, PDC, WCDMA, CDMA2000, or GPRS, among others.Such communication may occur, for example, through radio-frequencytransceiver 1068. In addition, short-range communication may occur, suchas using a Bluetooth, WiFi, or other such transceiver (not shown). Inaddition, GPS (Global Positioning System) receiver module 1070 mayprovide additional navigation- and location-related wireless data todevice 1050, which may be used as appropriate by applications running ondevice 1050.

Device 1050 may also communicate audibly using audio codec 1060, whichmay receive spoken information from a user and convert it to usabledigital information. Audio codec 1060 may likewise generate audiblesound for a user, such as through a speaker, e.g., in a handset ofdevice 1050. Such sound may include sound from voice telephone calls,may include recorded sound (e.g., voice messages, music files, etc.) andmay also include sound generated by applications operating on device1050.

The computing device 1050 may be implemented in a number of differentforms, as shown in the figure. For example, it may be implemented as acellular telephone 1080. It may also be implemented as part of a smartphone 1082, personal digital assistant, or other similar mobile device.

Various implementations of the systems and techniques described here canbe realized in digital electronic circuitry, integrated circuitry,specially designed ASICs (application specific integrated circuits),computer hardware, firmware, software, and/or combinations thereof.These various implementations can include implementation in one or morecomputer programs that are executable and/or interpretable on aprogrammable system including at least one programmable processor, whichmay be special or general purpose, coupled to receive data andinstructions from, and to transmit data and instructions to, a storagesystem, at least one input device, and at least one output device.

These computer programs (also known as programs, software, softwareapplications or code) include machine instructions for a programmableprocessor, and can be implemented in a high-level procedural and/orobject-oriented programming language, and/or in assembly/machinelanguage. As used herein, the terms “machine-readable medium”“computer-readable medium” refers to any computer program product,apparatus and/or device (e.g., magnetic discs, optical disks, memory,Programmable Logic Devices (PLDs)) used to provide machine instructionsand/or data to a programmable processor, including a machine-readablemedium that receives machine instructions as a machine-readable signal.The term “machine-readable signal” refers to any signal used to providemachine instructions and/or data to a programmable processor.

To provide for interaction with a user, the systems and techniquesdescribed here can be implemented on a computer having a display device(e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor)for displaying information to the user and a keyboard and a pointingdevice (e.g., a mouse or a trackball) by which the user can provideinput to the computer. Other kinds of devices can be used to provide forinteraction with a user as well; for example, feedback provided to theuser can be any form of sensory feedback (e.g., visual feedback,auditory feedback, or tactile feedback); and input from the user can bereceived in any form, including acoustic, speech, or tactile input.

The systems and techniques described here can be implemented in acomputing system that includes a back end component (e.g., as a dataserver), or that includes a middleware component (e.g., an applicationserver), or that includes a front end component (e.g., a client computerhaving a graphical user interface or a Web browser through which a usercan interact with an implementation of the systems and techniquesdescribed here), or any combination of such back end, middleware, orfront end components. The components of the system can be interconnectedby any form or medium of digital data communication (e.g., acommunication network). Examples of communication networks include alocal area network (“LAN”), a wide area network (“WAN”), and theInternet.

The computing system can include clients and servers. A client andserver are generally remote from each other and typically interactthrough a communication network. The relationship of client and serverarises by virtue of computer programs running on the respectivecomputers and having a client-server relationship to each other.

A number of implementations have been described. Nevertheless, it willbe understood that various modifications may be made without departingfrom the spirit and scope of the invention.

In addition, the logic flows depicted in the figures do not require theparticular order shown, or sequential order, to achieve desirableresults. In addition, other steps may be provided, or steps may beeliminated, from the described flows, and other components may be addedto, or removed from, the described systems. Therefore, otherimplementations are within the scope of any subsequently added claims.

What is claimed is:
 1. A method for synchronized media playback, themethod comprising: connecting, using a media playback device, to acommunications network, wherein the media playback device is associatedwith a media playback group that includes a plurality of media playbackdevices; receiving an indication that the media playback device has beendesignated as a follower playback device, wherein a remaining mediaplayback device in the media playback group is designated as a leaderplayback device; in response to receiving the indication that the mediaplayback device has been designated as the follower playback device,transmitting, from the follower playback device to the leader playbackdevice, a first series of synchronization requests, wherein a latencybetween two synchronization requests in the first series ofsynchronization requests is a first duration of time; receiving a firstseries of synchronization responses from the leader playback device;determining a clock offset between the follower playback device and theleader playback device based on at least a portion of the first seriesof synchronization responses; receiving, from the leader playbackdevice, an indication that media content is to be presentedsynchronously by the plurality of media playback devices in the mediaplayback group; in response to receiving the indication that mediacontent is to be presented synchronously by the plurality of mediaplayback devices, transmitting, from the follower playback device to theleader playback device, a second series of synchronization requests,wherein a latency between two synchronization requests in the secondseries of synchronization requests is a second duration of time, andwherein the second duration of time is shorter than the first durationof time; receiving a second series of synchronization responses from theleader playback device; determining an updated clock offset based on atleast a portion of the second series of synchronization responses;receiving a media stream for playback by the media playback group; andcausing the media stream to be played back on the follower playbackdevice in synchronization with the leader playback device based on theupdated clock offset.
 2. The method of claim 1, wherein the mediaplayback device has been designated as the follower playback device andthe remaining media playback device has been designated as the leaderplayback device based on a comparison of a measure of quality of a dataconnection of the first media playback device with the communicationsnetwork and a measure of quality of a data connection of the secondmedia playback device with the communications network.
 3. The method ofclaim 1, wherein the media playback device and the remaining mediaplayback device each include a respective record indicating membershipin the media playback group.
 4. The method of claim 3, wherein the mediaplayback group is a first media playback group and wherein therespective record of the media playback device further indicatesmembership in a second media playback group.
 5. The method of claim 1,further comprising receiving the media stream by the follower playbackdevice in a sequence of timestamped data packets.
 6. The method of claim1, wherein causing the media stream to be played back on the followerplayback device in synchronization with the leader playback device basedon the updated clock offset further comprises causing the media streamto be played back on the follower playback device in synchronizationwith the leader playback device based on the updated clock offset and anoutput delay of the follower playback device.
 7. The method of claim 1,wherein the clock offset is determined based on a round-trip-time (RTT)between the leader playback device and the follower playback device. 8.A system for synchronized media playback, the system comprising: ahardware processor of a media playback device, wherein the hardwareprocessor is configured to: connect to a communications network, whereinthe media playback device is associated with a media playback group thatincludes a plurality of media playback devices; receive an indicationthat the media playback device has been designated as a followerplayback device, wherein a remaining media playback device in the mediaplayback group is designated as a leader playback device; in response toreceiving the indication that the media playback device has beendesignated as the follower playback device, transmit, from the followerplayback device to the leader playback device, a first series ofsynchronization requests, wherein a latency between two synchronizationrequests in the first series of synchronization requests is a firstduration of time; receive a first series of synchronization responsesfrom the leader playback device; determine a clock offset between thefollower playback device and the leader playback device based on atleast a portion of the first series of synchronization responses;receive, from the leader playback device, an indication that mediacontent is to be presented synchronously by the plurality of mediaplayback devices in the media playback group; in response to receivingthe indication that media content is to be presented synchronously bythe plurality of media playback devices, transmit, from the followerplayback device to the leader playback device, a second series ofsynchronization requests, wherein a latency between two synchronizationrequests in the second series of synchronization requests is a secondduration of time, and wherein the second duration of time is shorterthan the first duration of time; receive a second series ofsynchronization responses from the leader playback device; determine anupdated clock offset based on at least a portion of the second series ofsynchronization responses; receive a media stream for playback by themedia playback group; and cause the media stream to be played back onthe follower playback device in synchronization with the leader playbackdevice based on the updated clock offset.
 9. The system of claim 8,wherein the media playback device has been designated as the followerplayback device and the remaining media playback device has beendesignated as the leader playback device based on a comparison of ameasure of quality of a data connection of the first media playbackdevice with the communications network and a measure of quality of adata connection of the second media playback device with thecommunications network.
 10. The system of claim 8, wherein the mediaplayback device and the remaining media playback device each include arespective record indicating membership in the media playback group. 11.The system of claim 10, wherein the media playback group is a firstmedia playback group and wherein the respective record of the mediaplayback device further indicates membership in a second media playbackgroup.
 12. The system of claim 8, wherein the hardware processor isfurther configured to receive the media stream by the follower playbackdevice in a sequence of timestamped data packets.
 13. The system ofclaim 8, wherein causing the media stream to be played back on thefollower playback device in synchronization with the leader playbackdevice based on the updated clock offset further comprises causing themedia stream to be played back on the follower playback device insynchronization with the leader playback device based on the updatedclock offset and an output delay of the follower playback device. 14.The system of claim 8, wherein the clock offset is determined based on around-trip-time (RTT) between the leader playback device and thefollower playback device.
 15. A non-transitory computer-readable mediumcontaining computer executable instructions that, when executed by aprocessor, cause the processor to perform a method for synchronizedmedia playback, the method comprising: connecting, using a mediaplayback device, to a communications network, wherein the media playbackdevice is associated with a media playback group that includes aplurality of media playback devices; receiving an indication that themedia playback device has been designated as a follower playback device,wherein a remaining media playback device in the media playback group isdesignated as a leader playback device; in response to receiving theindication that the media playback device has been designated as thefollower playback device, transmitting, from the follower playbackdevice to the leader playback device, a first series of synchronizationrequests, wherein a latency between two synchronization requests in thefirst series of synchronization requests is a first duration of time;receiving a first series of synchronization responses from the leaderplayback device; determining a clock offset between the followerplayback device and the leader playback device based on at least aportion of the first series of synchronization responses; receiving,from the leader playback device, an indication that media content is tobe presented synchronously by the plurality of media playback devices inthe media playback group; in response to receiving the indication thatmedia content is to be presented synchronously by the plurality of mediaplayback devices, transmitting, from the follower playback device to theleader playback device, a second series of synchronization requests,wherein a latency between two synchronization requests in the secondseries of synchronization requests is a second duration of time, andwherein the second duration of time is shorter than the first durationof time; receiving a second series of synchronization responses from theleader playback device; determining an updated clock offset based on atleast a portion of the second series of synchronization responses;receiving a media stream for playback by the media playback group; andcausing the media stream to be played back on the follower playbackdevice in synchronization with the leader playback device based on theupdated clock offset.
 16. The non-transitory computer-readable medium ofclaim 15, wherein the media playback device has been designated as thefollower playback device and the remaining media playback device hasbeen designated as the leader playback device based on a comparison of ameasure of quality of a data connection of the first media playbackdevice with the communications network and a measure of quality of adata connection of the second media playback device with thecommunications network.
 17. The non-transitory computer-readable mediumof claim 15, wherein the media playback device and the remaining mediaplayback device each include a respective record indicating membershipin the media playback group.
 18. The non-transitory computer-readablemedium of claim 17, wherein the media playback group is a first mediaplayback group and wherein the respective record of the media playbackdevice further indicates membership in a second media playback group.19. The non-transitory computer-readable medium of claim 15, wherein themethod further comprises receiving the media stream by the followerplayback device in a sequence of timestamped data packets.
 20. Thenon-transitory computer-readable medium of claim 15, wherein causing themedia stream to be played back on the follower playback device insynchronization with the leader playback device based on the updatedclock offset further comprises causing the media stream to be playedback on the follower playback device in synchronization with the leaderplayback device based on the updated clock offset and an output delay ofthe follower playback device.
 21. The non-transitory computer-readablemedium of claim 15, wherein the clock offset is determined based on around-trip-time (RTT) between the leader playback device and thefollower playback device.